package com.breeze.components.web.warm;

import com.breeze.components.web.warm.health.AppHealth;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.actuate.health.Status;

/**
 * @author breeze
 */
@Slf4j
public class WarmProcessor implements CommandLineRunner {

  Runnable runnable;

  public WarmProcessor(Runnable runnable) {
    this.runnable = runnable;
  }

  @Override
  public void run(String... args) throws Exception {
    log.info("---------------启动预热组件---------------");
    runnable.run();
    AppHealth.status = Status.UP;
    log.info("---------------预热结束--->{}", AppHealth.status);
  }
}
